import apis from "../services/userInfoApi";

export default {
  namespace: "userInfo",
  state: {
    userName: "",
    userSex: "",
    userType: "",
    orgName: "",
    userPartType: "",
    userPoliceId: "",
    customEmail: "",
    customMobile: ""
  },
  effects: {
    *getUserInfo({ payload = {} }, { call, put }) {
      const res = yield call(apis.getUserInfo, payload);
      const { datas = {} } = res;
      yield put({
        type: "setState",
        payload: datas
      });
    },
    *updateUserInfo({ payload = {} }, { call }) {
      return yield call(apis.updateUserInfo, payload);
    }
  },
  reducers: {
    setState: (state, { payload = {} }) => ({
      ...state,
      ...payload
    })
  }
};
